GBML manual / Device

rumble

Makes a cartridge with a rumble motor shake for `frames` frames, then stops by itself.

Works differently on Game Boy - A Game Boy game rumbles only if its project is set to a rumble cartridge (Settings: Rumble cartridge); in any other game rumble and rumble_stop do nothing.

Works differently on Game Boy Color - A Game Boy Color game rumbles only if its project is set to a rumble cartridge (Settings: Rumble cartridge); in any other game rumble and rumble_stop do nothing.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

rumble(frames)

Arguments

NameType
framesint

Returns

Nothing.

Description

Makes a cartridge that has a rumble motor in it shake for frames frames, then stop by itself. One frame is one sixtieth of a second, so rumble(30) is half a second of buzzing.

Some Game Boy Advance cartridges carry a small motor, like the one in a game controller. Drill Dozer and WarioWare: Twisted! are two that do. This is the call that turns it on.

It always stops by itself

There is no "rumble on" that you have to remember to switch off. You say how long, and the game counts the frames down and stops the motor when they run out. That is on purpose. A motor that gets stuck on is much worse than a sprite that gets stuck: you cannot ignore it, and it eats the batteries. If your code stops halfway (an object gets destroyed in the middle of an effect, say), the rumble still ends on time.

If you need to cut one short, rumble_stop stops it at once.

How many frames?

The frame you call it in counts as the first. rumble(1) is over before the picture is even shown, so you will not feel it. A tap you can feel is about 8 to 15 frames. A big explosion might be 30 to 60.

The longest one call can ask for is 600 frames, which is ten seconds. Ask for more and it is cut down to 600; it is not an error. 0 or less does nothing at all.

Keeping it going

If you call rumble again while one is already running, the later finish wins. A short call can never cut a long one short. So to hold the motor on for as long as something is true, call rumble(3) every frame while it is. Each call tops the count back up to 3, and when the thing stops being true the motor stops three frames later.

The count keeps going while the game is paused, during a cutscene and across a room change, so a rumble that starts just before you walk through a door still finishes.

On a cartridge with no motor, and in emulators

Almost every cartridge has no motor, and the game does not know which kind it is in. Asking for a rumble is always safe: a cartridge without a motor just ignores it. Nothing breaks and nothing shakes.

An emulator can be a little chattier. The mGBA emulator, for one, writes a note in its log window that the game poked at hardware the cartridge does not have, and carries on. It never shows a message on the screen.

This is the rumble motor in the cartridge. It is not the Game Boy Player's rumble, which is a different thing, and this call does not drive it. The Game Boy Color cannot use this call, and the checker says so if you try.

Example

// The hero touched the spikes: a thump you can feel and a jolt you can see.
rumble(12);
camera_shake(4, 12);

In a Collision event, this gives a short hit: a rumble of 12 frames (a fifth of a second) together with a small camera jolt of the same length.

// Hold A to keep the cartridge buzzing. Let go and it stops three frames later.
if (btn_held(BTN_A)) {
    rumble(3);
}

A Step event runs every frame, so this tops the count back up to 3 on every frame A is down. The moment A is let go, no more top-ups come and the motor stops.

On the GBA

Drives the motor that cartridges like Drill Dozer and WarioWare: Twisted! have, through the cartridge’s own pins (bit 3 at 0x080000C4). A cartridge without a motor ignores it - nothing breaks, nothing warns, nothing shakes - and neither the game nor the engine can tell which kind of cartridge it is. There is deliberately no plain “rumble on”: the countdown is the only way to start the motor, so a script that stops early can never leave it running. The frame you call it in counts as the first, so about 8 to 15 is a tap you can feel; the longest one call can ask for is 600 (ten seconds), and more is cut down to that. Calling it again while it runs keeps whichever finish is later, so `rumble(3)` every frame holds the motor for as long as something stays true and ends three frames after it stops. It keeps counting through a pause, a cutscene and a room change. It does not drive the Game Boy Player’s rumble, which is a separate mechanism.

See also: rumble_stopcamera_shakebtn_held